import java.util.StringTokenizer;
import java.util.Vector;

class P156 {

	private static Vector v;
	private static Vector ananagram;

	public static void main(String[] args) {
		String line = readLn();
		v = new Vector();
		ananagram = new Vector();
		while (!line.equals("#")) {
			store(line);
			line = readLn();
		}
		process();
	}

	private static void process() {
		int length = v.size();
		for (int k = 0; k < length; k++) {
			subProcess((String)v.elementAt(k), v);
		}
		
		sortWords(ananagram);
		for (int k = 0; k <  ananagram.size(); k++) {
			System.out.println(ananagram.elementAt(k));
		}
	}
	
	private static void sortWords(Vector words) {
	       quickSortWords(words, 0, words.size() - 1);
	   }

	   private static void quickSortWords(Vector vector, int i, int j) {
	       if (i < j) {
	           int q = partition(vector, i, j);
	           quickSortWords(vector, i, q - 1);
	           quickSortWords(vector, q + 1, j);
	       }
	   }

	   private static int partition(Vector vector, int p, int r) {
	       String x = (String)vector.elementAt(r);
	       int i = p - 1;
	       for (int j = p; j < r ; j++) {
	           if (((String)vector.elementAt(j)).compareTo(x) <= 0) {
	               i = i + 1;
	               swap(vector, i, j);
	           }
	       }
	       swap(vector, i + 1, r);
	       return i + 1;
	   }

	   private static void swap(Vector vector, int i, int r) {
	       String aux = (String)vector.elementAt(i);
	       vector.setElementAt(vector.elementAt(r), i);
	       vector.setElementAt(aux, r);
	   }
	

	private static void subProcess(String x, Vector v) {
		int length = v.size();
		for (int j = 0; j < length; j++) {
			String x2 = (String)v.elementAt(j);
			if (!x.equalsIgnoreCase(x2) && isAnagram(x,x2)) {
				return;
			}
		}
		ananagram.addElement(x);
		
	}

	private static boolean isAnagram(String x1, String x2) {
		if (x1.length() != x2.length()) {
			return false;
		}
		int[] xA1 = new int[26];
		int[] xA2 = new int[26];
		
		for (int k = 0; k < x1.length(); k++) {
			char c1 = x1.charAt(k);
			c1 = Character.toLowerCase(c1);
			char c2 = x2.charAt(k);
			c2 = Character.toLowerCase(c2);
			xA1[((int)c1)-'a']++;
			xA2[((int)c2)-'a']++;
		}
		return analise(xA1, xA2);
	}

	private static boolean analise(int[] xa1, int[] xa2) {
		for (int k = 0; k < 26; k++) {
			if (xa1[k] != xa2[k]) {
				return false;
			}
		}
		return true;
	}

	private static void store(String line) {
		StringTokenizer st = new StringTokenizer(line);
		while (st.hasMoreTokens()){
			v.addElement(st.nextToken());
		}

	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}